import time
from public.action import *
from public.business import *
from public.testData import *
from public.tools import*

testCase="DBshop006_删除已取消订单"
# 下拉框定位方法
from selenium.webdriver.support.select import Select #1.导入Select

# 登录后台
firefox=openBrowser(urlAdmin)
# 12.登录管理员账号
DBshopLoginAdmin(firefox)
#13.调用二级目录函数 点击销售管理-订单管理
DBshopEnterMenu2(firefox,"销售管理","订单管理")
# 订单状态选择 取消
firefox.find_element_by_id("order_state").click()
firefox.find_element_by_xpath("//option[text()='已取消']").click()
# 点击搜索
firefox.find_element_by_xpath("//p//button[@type='submit']").click()
# 全选操作
firefox.find_element_by_id("select_checkbox_state_1").click()
# 下拉 选择
s=firefox.find_element_by_id("allEdit")#2.把下拉框存入变量s
a=Select(s)#3.实例化Select
a.select_by_index(1)#4.下标定位

# 提交操作
firefox.find_element_by_xpath("//i[@class='icon-ok icon-white']").click()
firefox.switch_to_alert().accept()


firefox.find_element_by_id("order_state").click()
firefox.find_element_by_xpath("//option[text()='已取消']").click()
# 点击搜索
firefox.find_element_by_xpath("//p//button[@type='submit']").click()

s=firefox.find_element_by_xpath("//strong").text
# print(s)
l="订单数\："
r="\)"
num=reGetString(s,l,r)
if num=="0":
    writeLog("%s 测试通过" % (testCase))
else:
    writeLog("%s 测试失败" % (testCase))
    getPhoto(firefox)
firefox.quit()
